import 'package:boss/models/sku.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:provider/provider.dart';
import 'package:router/annotation.dart';

import 'provider/sku_provider.dart';
import 'widget/sku_browser.dart';

@RouterConfig(SkuSettingPage.pageName)
class SkuSettingPage extends StatefulWidget {
  static const pageName = '/skuSettingPage';

  @Autowired()
  final List<Sku> skus;
  @Autowired()
  final int price;
  @Autowired()
  final int salePrice;
  @Autowired()
  final int vipPrice;

  const SkuSettingPage({
    this.skus,
    this.price,
    this.vipPrice,
    this.salePrice,
  });

  @override
  _SkuSettingPageState createState() => _SkuSettingPageState('添加菜品多规格');
}

class _SkuSettingPageState extends BaseState<SkuSettingPage> {
  _SkuSettingPageState(String pageName) : super(pageName);

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (context) => SkuProvider(
        skus: widget.skus,
        price: widget.price,
        salePrice: widget.salePrice,
        vipPrice: widget.vipPrice,
      ),
      child: Scaffold(
        appBar: CenterTitleAppBar(title: '多规格设置'),
        body: SkuBrowser(),
      ),
    );
  }
}
